package com.ljw.spring.annotation.ext;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @FileName MyBeanFactoryPostProcessor
 * @Description TODO
 * @Author ljw
 * @Date 2021/2/4 1:36
 * @Version 1.0
 */
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

        System.out.println("MyBeanFactoryPostProcessor------postProcessBeanFactory()");
        String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
        int count = beanFactory.getBeanDefinitionCount();
        System.out.println("当前beanFactory中bean的数量："+count);
        System.out.println(Arrays.toString(beanDefinitionNames));
    }
}
